﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using WcfRestfulTest.Modal;
using System.ServiceModel.Activation;

namespace WcfRestfulTest
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码、svc 和配置文件中的类名“Service1”。
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class Service1 : IService1
    {
        public UserInfo GetUserInfoByCode(string code)
        {
            IList<UserInfo> list = new List<UserInfo>(){
              new UserInfo(){ Id=1, Code="000001", Name="乔峰", Description="乔大爷啊"},
               new UserInfo(){ Id=2, Code="600000", Name="段誉", Description="你爹真是风流倜傥啊"},
              new UserInfo(){ Id=3, Code="000002", Name="慕容复", Description="妹子被楼上的抢咯，太失败了"},
               new UserInfo(){ Id=4, Code="000008", Name="庄聚贤", Description="无所事事的帅哥庄聚贤"},
            };
            var item = list.Where(e => string.Equals(e.Code, code, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
            return item;
        }

        public UserInfo Register(UserInfo userInfo)
        {
            if (null == userInfo)
            {
                return null;
            }
            userInfo.Description = "Post OK";
            return userInfo;
        }
    }
}
